Skip to content

feat(id): currency registry schema + ledger-u32 allocator (#2317) - #10658

Merged
dezren39 merged 1 commit into
mainfrom
queue/17444-2317-currency-registry
Nov 16, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/17444-2317-currency-registry

Conversation

@dezren39

@dezren39 dezren39 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Closes #2317. Slice F1 of the #2062 currency control-plane design — the registry that owns the meaning of a TigerBeetle ledger u32.

What

New crate pkgs/id/crates/id-currency-registry (workspace member):

  • Postgres migration migrations/0001_currency_registry.up.sql (+ down) creating the four tables with the constraints the design names:
    • ledger_allocation (§2.1) — ledger_id bigint PK with the 0..4294967295 check, per-kind range check enforcing the ratified §6 split (1..=0xFFFFF tenancy/system, 0x100000.. currencies), monotonic allocator sequences + allocate_ledger(kind, owner_ref), and a trigger refusing deletes (ids are never recycled).
    • currency (§2.2) — currency_id globally UNIQUE, (issuer_id, symbol) UNIQUE (symbol unique per issuer, not globally), graph_object_id linkage to the signed canonical record (§2.4), supply policy / status / scale per the design.
    • currency_issuer and account — drafted from §4.2 / §3 per decision 4 (the design names them but does not tabulate their columns), marked as draft-for-ratification in the migration, crate docs, and README.
  • Rust semantics over a Store seam (Allocator, Registry, in-memory store enforcing the same constraints): monotonic non-zero allocation, no recycle (no release API; the store refuses a spent id), currency_id minting at registration with duplicate rejection before a ledger id is spent, issuer-only grant_minter, and the factory-account index.

Decisions applied (ledger currency-registry-decisions-2317, answered 2026-11-16, recorded on #2317): Postgres store; bigint + range check; currency_id global / symbol per issuer; fleet-drafted currency_issuer/account columns.

Tests (oracle: #2317 acceptance)

  • cargo test -p id-currency-registry — 11/11 pass, incl. two issuers both registering symbol ABC, duplicate currency_id rejected, duplicate (issuer, symbol) rejected, allocator monotonic/non-zero/range-split/no-recycle. Clippy clean, cargo fmt clean.
  • scripts/test-migration.sh — PASS against a real throwaway Postgres: migration applies; allocator hands out 1048576, 1048577, system 1; delete (recycle) refused; two issuers with symbol ABC insert fine; duplicate currency_id and duplicate (issuer, symbol) rejected; out-of-range allocation rejected; down migration removes the schema.

Queue: task 17444, lane any-a.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Slice F1 of the #2062 currency control-plane design: Postgres migration creating ledger_allocation, currency, currency_issuer and account with the ratified range split, plus the id-currency-registry crate stating the allocator/registry semantics (monotonic, never recycled, currency_id globally unique, symbol unique per issuer).
@dezren39
dezren39 requested a review from a team as a code owner November 16, 2026 09:24
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T09:24:05.166836Z
We couldn’t complete this review. Comment @codex review to try again.
3f0dc87 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c455c6ca-3f52-418e-9458-cca27cba14e4
Commits

Reviewing files that changed from the base of the PR and between 37e5faa and 3f0dc87.

Files ignored due to path filters: 1

  • pkgs/id/Cargo.lock is excluded by !**/*.lock
Files selected for processing: 11

  • pkgs/id/Cargo.toml
  • pkgs/id/crates/id-currency-registry/Cargo.toml
  • pkgs/id/crates/id-currency-registry/README.md
  • pkgs/id/crates/id-currency-registry/migrations/0001_currency_registry.down.sql
  • pkgs/id/crates/id-currency-registry/migrations/0001_currency_registry.up.sql
  • pkgs/id/crates/id-currency-registry/scripts/test-migration.sh
  • pkgs/id/crates/id-currency-registry/src/allocator.rs
  • pkgs/id/crates/id-currency-registry/src/lib.rs
  • pkgs/id/crates/id-currency-registry/src/registry.rs
  • pkgs/id/crates/id-currency-registry/src/store.rs
  • pkgs/id/crates/id-currency-registry/tests/acceptance.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: merge_ready (review-findings disposition)

  • Agent: queue worker (repo-worker-code), lane any-a, task 17444

Codex findings gate disposition: the Codex review on this PR FAILED before producing any finding — its summary comment records status "failed" and a second comment states the Codex usage limit for code reviews is reached. Verified this shift: zero Codex review comments (pulls/10658/comments is empty) and zero reviews, so there is no finding to fix or rebut. CodeRabbit likewise posted only a rate-limit notice (free OSS review limit, resets in ~40 min), with no findings.

Merging on local verification instead, per the fleet merge rule (CI runs on main; PRs do not wait): cargo test -p id-currency-registry 11/11 pass, clippy clean, fmt clean, and scripts/test-migration.sh PASS against a real Postgres covering every #2317 acceptance item.

@dezren39
dezren39 merged commit 454547f into main Nov 16, 2026
1 check passed
@dezren39
dezren39 deleted the queue/17444-2317-currency-registry branch November 16, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id(currency): currency registry schema + ledger-u32 allocator (from #2062)

1 participant